package com.company.thread;

import com.company.singleton.Singleton;

/**
 * @description: some desc
 * @author: ruoan
 * @date: 2020/12/8 13:13
 */
public class SingletonDemo1 {
    private static SingletonDemo1 instance;

    private SingletonDemo1() {
        System.out.println(Thread.currentThread().getName()+"在构造器");
    }

    public static SingletonDemo1 getInstance(){
        if (instance == null) {
            instance = new SingletonDemo1();
        }
        return instance;
    }


    public static void main(String[] args) {


        System.out.println(SingletonDemo1.getInstance() == SingletonDemo1.getInstance());
        System.out.println(SingletonDemo1.getInstance() == SingletonDemo1.getInstance());
    }
}
